﻿/* Write a program that reads two numbers N and K and generates all the variations of K elements from the set [1..N]. 
 * Example:
	N = 3, K = 2  {1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}
*/




using System;

class NKVariations
{
    static void Main()
    {
        int N, K;

        bool iProvided = false;
        do
        {
            if (iProvided == true) Console.WriteLine("Error occurred. Please enter an integer.");
            else iProvided = true;
            Console.Write("Enter N: ");
        } while (Int32.TryParse(Console.ReadLine(), out N) == false);

        iProvided = false; //reset iProvided
        do
        {
            if (iProvided == true) Console.WriteLine("Error occurred. Please enter an integer.");
            else iProvided = true;
            Console.Write("Enter K: ");
        } while (Int32.TryParse(Console.ReadLine(), out K) == false);

        //int[] arr = new int[K];
        string variationStr = null;
        int? curr = null;
        
        for (int i = 0; i < N; i++)
        {
            curr = i+1; //getting main number
            //variationStr += "{"+i+1;
            for (int j = 0; j <= K; j++) variationStr += "{" + curr + ", " + (j+1) + "}"; //adding K sets
            variationStr += "\r\n";
        }
        Console.WriteLine("Variations: " + variationStr);

    }
}
